<!DOCTYPE html>
<html lang="en">
<head>
    {{include file="lib/page_head" /}}
    <link href="/css/bootstrap-editable.css" rel="stylesheet">

    <style>
        table th{word-wrap:break-word;word-break:break-all;font-size:12px!important;}
        table td{word-wrap:break-word;word-break:break-all;font-size:12px!important;}
        .from_table .td_l,.from_table .td_r{font-size:14px!important;line-height: 25px;word-wrap:break-word;word-break:break-all}
        #search_form .form-control,#search_form .select5{width:100px;height:28px;padding:5px;}
        #search_form .layui-input-inline{width:auto;margin: 0;}
        #search_form .form-group{margin-right:0;margin-bottom: 5px;}
        #search_form .btn{height:30px;line-height:30px;padding:0 10px;}
    </style>
</head>

<body>



<!-- Preloader -->
<div id="preloader">
    <div id="status"><i class="fa fa-spinner fa-spin"></i></div>
</div>

<section>
    {{include file="lib/page_left" /}}
    <div class="mainpanel">

        {{include file="lib/page_header" /}}

        <div class="contentpanel" >
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-btns">
                        <a href="" class="panel-close">×</a>
                        <a href="" class="minimize">−</a>
                    </div>
                    <h4 class="panel-title">配置列表</h4>
                </div>
                <div class="panel-body form-horizontal">
                    <div id="info_list" class="form-inline">
                        <div class="btn-group">
                            <!--<button class="btn btn-primary" onclick="edit_info(0)">添加</button>-->
                            <!--<button class="btn btn-primary" onclick="del_info(0)">删除</button>-->
                            <!--<button class="btn btn-primary" onclick="set_cancel(0)">取消</button>-->
                            <button class="btn btn-primary" onclick="location.href = location.href;">刷新</button>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">余额宝利率</label>
                        <div class="col-sm-6" >
                            <a  data-name="BALACE_TREASURE" data-type="text" class="editable editable-click" data-value="{{$config_list['BALACE_TREASURE']['value']}}">{{$config_list['BALACE_TREASURE']['value']}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">折扣</label>
                        <div class="col-sm-6" >
                            <a  data-name="DISCOUNT" data-type="text" class="editable editable-click" data-value="{{$config_list['DISCOUNT']['value']}}">{{$config_list['DISCOUNT']['value']}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">代理折扣</label>
                        <div class="col-sm-6" >
                            <a  data-name="AGENT_DISCOUNT" data-type="text" class="editable editable-click" data-value="{{$config_list['AGENT_DISCOUNT']['value']}}">{{$config_list['AGENT_DISCOUNT']['value']}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">卡费</label>
                        <div class="col-sm-6" >
                            <a  data-name="CARD_FEE" data-type="text" class="editable editable-click" data-value="{{$config_list['CARD_FEE']['value']/10000}}">{{$config_list['CARD_FEE']['value']/10000}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">运费</label>
                        <div class="col-sm-6" >
                            <a  data-name="FREIGHT" data-type="text" class="editable editable-click" data-value="{{$config_list['FREIGHT']['value']/10000}}">{{$config_list['FREIGHT']['value']/10000}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" style="width:100px;">分成率(<a href="javascript:void 0;" onclick="add_rebate(this)">+</a>)</label>
                        <div class="col-sm-6" id="rebate_list">
                            {{foreach $config_list['USER_REBATE']['value'] as $key=>$val }}
                            <div>
                                <a data-name="USER_REBATE" data-type="text" class="editable editable-click" data-value="{{$val}}" data-t="list">{{$val}}</a>
                                <a href="javascript:void 0;" data-name="USER_REBATE" data-t="list" onclick="del_rebate(this)" style="color:red;">删除</a>
                            </div>
                            {{/foreach}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">代理商分成率</label>
                        <div class="col-sm-6" >
                            <a  data-name="AGENT_REBATE" data-type="text" class="editable editable-click" data-value="{{$config_list['AGENT_REBATE']['value']}}">{{$config_list['AGENT_REBATE']['value']}}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">充值维护</label>
                        <div class="col-sm-6" >
                            <input type="checkbox" value="1" data-name="RECHARGE_LOCK" name="RECHARGE_LOCK" {{if $config_list.RECHARGE_LOCK.value }}checked="checked"{{/if}} />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">充值维护内容</label>
                        <div class="col-sm-6" >
                            <a  data-name="RECHARGE_LOCK_CONTENT" data-type="text" class="editable editable-click" data-value="{{$config_list['RECHARGE_LOCK_CONTENT']['value']}}">{{$config_list['RECHARGE_LOCK_CONTENT']['value']}}</a>

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"  style="width:100px;">老卡限制额度</label>
                        <div class="col-sm-6" >
                            <a  data-name="MAX_PRICE" data-type="text" class="editable editable-click" data-value="{{$config_list['MAX_PRICE']['value']/10000}}">{{$config_list['MAX_PRICE']['value']/10000}}</a>

                        </div>
                    </div>

                </div>
            </div>
        </div><!-- contentpanel -->

    </div><!-- mainpanel -->
    {{include file="lib/page_right" /}}
</section>

<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../js/jquery-migrate-1.2.1.min.js"></script>
<script src="../js/jquery-ui-1.10.3.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.sparkline.min.js"></script>
<script src="../js/toggles.min.js"></script>
<script src="../js/jquery.cookies.js"></script>
<script src="../js/jquery.tmpl.js"></script>
<script src="../js/custom.js"></script>

<script src="../js/jquery.gritter.min.js"></script>
<script src="../js/form.beautify.js?t={{$version}}"></script>
<script src="../js/commen.js?t={{$version}}"></script>
<script src="../js/datatables.js?t={{$version}}"></script>
<link href="../css/ley.dialog.css" rel="stylesheet">
<script src="../js/ley.dialog.js?t={{$version}}"></script>
<script src="../js/bootstrap-editable.min.js"></script>
<script>

    jQuery(document).ready(function() {

        // Basic Popup Example
        jQuery('.editable').editable({
            display:function(value)
            {
                var value1 = $(this).attr("data-value");
                if(value != value1)
                {
                    $(this).html(value);
                    $(this).attr("data-value",value);
                    var _this = $(this);
                    var name = _this.attr("data-name");
                    var t = _this.attr("data-t");
                    save(name,t);
                }
            }
        });
        jQuery('#rebate_list').editable({
            pk: 1,
            selector: 'a',
            display:function(value)
            {
                var value1 = $(this).attr("data-value");
                if(value != value1)
                {
                    $(this).html(value);
                    $(this).attr("data-value",value);
                    var _this = $(this);
                    var name = _this.attr("data-name");
                    var t = _this.attr("data-t");
                    save(name,t);
                }
            }
        });
        jQuery("input[name='RECHARGE_LOCK']").change(function () {
            var value = 0;
            if($(this).attr("checked"))
            {
                value = 1;
            }
            AjaxCommen("GET","/configs/ajax_config_save",{name:"RECHARGE_LOCK",value:value},function (msg) {
                location.href = location.href;
            });
        });

    });
    function save(name,t)
    {
        var list = [];
        $("a[data-name='"+name+"']").each(function (i) {
            var value = $(this).attr("data-value");
            if(t == "list")
            {
                list.push(value);
            }else{
                list = value;
            }
        });
        AjaxCommen("GET","/configs/ajax_config_save",{name:name,value:list},function (msg) {
            location.href = location.href;
        });
    }
    function del_rebate(obj)
    {
        var _this = $(obj);
        var name = _this.attr("data-name");
        var t = _this.attr("data-t");
        _this.parent("div").remove();
        save(name,t);
    }
    function add_rebate(obj)
    {
        var text = '<div>\n' +
            '   <a data-name="USER_REBATE" data-type="text" class="editable editable-click" data-value="0" data-t="list">0</a>\n' +
            '  <a href="javascript:void 0;" data-name="USER_REBATE" data-t="list" onclick="del_rebate(this)" style="color:red;">删除</a>\n' +
            ' </div>';
        console.log($(obj).html())
        $(obj).parent().next().append(text);
    }

</script>
</body>
</html>
